package com.bk.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Ayi
 */
// 工具类
public class ToolUtil {

    // 判断id还是Name
    public boolean judgeIdOrName(String idOrNameInfo) {
        try {
            Integer.parseInt(idOrNameInfo);
            return true;
        }catch (NumberFormatException e) {
            return false;
        }
    }

    // 随机数0\1生成
    public int randomNumber() {
        long time = System.currentTimeMillis();
        return time % 2 == 0 ? 0 : 1;
    }

    // 返回当前日期-年月日时分
    public String getDate() {
        long time = System.currentTimeMillis();
        Date date = new Date(time);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分");
        return sdf.format(date);
    }
}
